<template>
  <div class="table-container">
    <el-table v-loading="page.loading" :border="false" :data="page.list" :show-header="false">
      <el-table-column label="考试">
        <template #default="scope">
          <div class="exam-info">
            <exam-tag :exam-type="scope.row.examType" :is-text="false" />
            <div class="paper-info">
              <div class="title">{{ scope.row.examName }}</div>
              <span class="mr20">状态：<common-enum-view :enum-value="scope.row.userExamStatus" :enum-name="'UserExamStatus'" /></span>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column :width="200" align="center" label="操作">
        <template #default="scope">
          <nuxt-link :to="{ name: 'exam-detail', query: { id: scope.row.examId } }">
            <el-button link type="primary"> 前往查看</el-button>
          </nuxt-link>
        </template>
      </el-table-column>
    </el-table>
    <common-pagination v-model:current-page="page.pageCurrent" v-model:page-size="page.pageSize" :total="page.totalCount" @pagination="handlePage" />
  </div>
</template>
<script setup>
  import useTable from '~/utils/table.js'
  import { examApi } from '~/api/exam'

  const props = defineProps({
    examType: {
      type: Number,
      default: 0
    }
  })

  const { page, handlePage } = useTable(
    {
      page: examApi.examUserPage
    },
    {
      examType: props.examType === 0 ? undefined : props.examType
    }
  )
</script>
<style lang="scss" scoped>
  .exam-info {
    display: flex;
    flex-direction: row;
  }
  .paper-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 20px;
  }
</style>
